DXL attriube receiving input from another multi-valued enum attribute within the current object

Hello, 

I want to create a DXL attribute column that would display test using a multi-valued attribute from each current object as its input.

Feature Set: multi-valued attribute
Feature 1
Feature 2
Feature 3
Feature 4

For example, the test it would display would be "Model number 23" if it has Feature 1 and Feature 2, it would display "Model number 26" if it only has Feature 3, and etc...

Does anyone know how I can do this or where I can find an example similar to this or do you have any code examples of your own.

Thanks!


rymcclel - Tue Apr 15 14:38:47 EDT 2014

Re: DXL attriube receiving input from another multi-valued enum attribute within the current object
llandale - Wed Apr 16 12:59:04 EDT 2014

This isn't perfect but should get you started.

string NameAttrEnum = "Features"

string Result

AttrDef ad = find(NameAttrEnum)

if (null ad) then {obj.attrDXLName = "Error"; halt}

bool f1 = isMember(obj.NameAttrEnum, "Feature 1"),

    f2 = isMember(obj.NameAttrEnum, "Feature 2"),

    f3 = isMember(obj.NameAttrEnum, "Feature 3")

   f4 = isMember(obj.NameAttrEnum, "Feature 4")

if     ( f1 and  f2 and  f3 and  f4)  then Result = "Error"

elseif ( f1 and  f2 and  f3 and !f4)  then Result = "45"

..

elseif ( f1 and  f2 and !f3 and !f4)  then Result = "23"

...

elseif (!f1 and !f2 and  f3 and !f4)  then Result = "26"

elseif there are 15 elseif statements in this truth table

obj.attrDXLName = "Model number " Result

Re: DXL attriube receiving input from another multi-valued enum attribute within the current object
rymcclel - Wed Apr 16 16:19:03 EDT 2014

llandale - Wed Apr 16 12:59:04 EDT 2014

This isn't perfect but should get you started.

string NameAttrEnum = "Features"

string Result

AttrDef ad = find(NameAttrEnum)

if (null ad) then {obj.attrDXLName = "Error"; halt}

bool f1 = isMember(obj.NameAttrEnum, "Feature 1"),

    f2 = isMember(obj.NameAttrEnum, "Feature 2"),

    f3 = isMember(obj.NameAttrEnum, "Feature 3")

   f4 = isMember(obj.NameAttrEnum, "Feature 4")

if     ( f1 and  f2 and  f3 and  f4)  then Result = "Error"

elseif ( f1 and  f2 and  f3 and !f4)  then Result = "45"

..

elseif ( f1 and  f2 and !f3 and !f4)  then Result = "23"

...

elseif (!f1 and !f2 and  f3 and !f4)  then Result = "26"

elseif there are 15 elseif statements in this truth table

obj.attrDXLName = "Model number " Result

Hi, thanks for the great starting point!

I do have one question about it though, lets say that I want it to display multiple model numbers such as "26" and "23" for some cases, can I just do Result += "23" and Result +="26", and If I wanted to remove one in another condition could i just do Result -= "23",

Thanks

Re: DXL attriube receiving input from another multi-valued enum attribute within the current object
llandale - Thu Apr 17 10:28:02 EDT 2014

rymcclel - Wed Apr 16 16:19:03 EDT 2014

Hi, thanks for the great starting point!

I do have one question about it though, lets say that I want it to display multiple model numbers such as "26" and "23" for some cases, can I just do Result += "23" and Result +="26", and If I wanted to remove one in another condition could i just do Result -= "23",

Thanks

"+=" and "-=" won't work on a "string".  "+=" will work on a "Buffer"' but two "+=" in a row looks like "2326" and you cannot "-=".

Got an algorithm problem?  Write down your algorithm in English (or native language).  Try two approaches; I like starting with #2, making sure you have exactly one "result is 23" line.  Once that is correct, translate it into form #1.

  1. when (list of conditions) then the result is 23
  2. the result is 23 when(list of conditions)

Anyway. The 16 case statement I outlined will work.  The "mutually exclusive" feature helps <me>; although I think other folks don't need that conceptual crutch.  If I had to do it sequencially as you suggest, then I suppose you'd need these additional variables:

  • bool b23 = false, b26 = false, b45 =  false, etc

Then set them true and false accordingly:

  • if (whatever) then b23 = true
  • if (whatever else) then b45 = true
  • if (another and b23) then {b23 = false; b26 = true}
  • if (But Wait!!!) then confuse the reader even more.

I expect you will find it very dificult to write the comments that expain that (to low intellect folks like Managers); but if you can then go for it.

-Louie